import React, {useState, useRef, useEffect} from 'react';

function ExampleHook9(){
  const inputEl = useRef(null)
  const onButtonClick = ()=>{
    inputEl.current.value = "Hello,Zhaozb"
    console.log(inputEl)
  }

  const [text, setText] = useState("qishon")
  const textRef = useRef()
  useEffect(()=>{
    textRef.current = text
    console.log('textRef.current', textRef.current)
  })
  return(
    <>
      <input type="text" ref={inputEl}/>
      <button onClick={onButtonClick}>在input上展示文字</button>
      <br/>
      <br/>
      <input type="text" value={text} onChange={(e)=>{setText(e.target.value)}}/>
    </>
  )
}
export default ExampleHook9